package com.yuki.fwwb.Controller;

import com.yuki.fwwb.Entity.Cluster;
import com.yuki.fwwb.Entity.Ticket;
import com.yuki.fwwb.Entity.WeekInOut;
import com.yuki.fwwb.Service.TripsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Api(value = "查询")
@RestController
@CrossOrigin(origins = "http://localhost:9000", maxAge = 3600)
public class TripsController {

    @Autowired
    TripsService service;

    @ApiOperation(value = "通过月份分组查询全年客流量")
    @PostMapping("/findMonthSum")
    public List<Map> findMonthSum(){
        return service.findMonthSum();
    };
 /*   *//**
     * 通过渠道类型，弃用
     * @return
     *//*

    @RequestMapping("/findChannelNumberSum")
    public List<Map> findChannelNumberSum(){
        return service.findChannelNumberSum();
    };*/
    /**
     * 查询某个月 每个星期几的客流量的和
     * @param month 月份
     * @return
     */
    @ApiOperation(value = "查询某个月 每个星期几的客流量的和")
    @PostMapping("/findWeekOfMonth")
    public List<Map> findByWeekOfMonth(@RequestParam("month") int month){
        return service.findByWeekOfMonth(month);
    };
    /**
     * 当周总客流量
     * @param week 一年当中第几个周
     * @return
     */
    @ApiOperation(value = "当周总客流量   week:一年当中第几个周")
    @PostMapping("/findByWeekAll")
    public List<Map> findByWeekAll(@RequestParam("week") int week){
        return service.findByWeekAll(week);
    };
    /**
     * 当周每天客流量
     * @param week 一年当中第几个周
     * @return
     */
    @ApiOperation(value = "当周每天客流量 week：一年当中第几个周")
    @PostMapping("/findByWeek")
    public List<Map> findByWeek(@RequestParam("week") int week){
        return service.findByWeek(week);
    };
    /**
     * 某个月每一天的客流量
     * @param month
     * @return
     */
    @ApiOperation(value = "某个月每一天的客流量  ")
    @PostMapping("/findByMonthDay")
    public List<Map> findByMonthDay(@RequestParam("month") int month){
        return service.findByMonthDay(month);
    }
    /**
     * 某个月的某一天的各个站点的进出人数
     * @param month
     * @param day
     * @return
     */
    @ApiOperation(value = "某个月的某一天的各个站点的进出人数")
    @PostMapping("/findByOneDayAllStationInOutOfMonth")
    public List<Map> findByOneDayAllStationInOutOfMonth(@RequestParam("month") int month,@RequestParam("day") String day
                                                       ){
        return service.findByOneDayAllStationInOutOfMonth(month,day);
    };
    /**
     * 某个月的各个站点的进出人数
     * @param month
     * @return
     */
    @ApiOperation(value = "某个月的各个站点的进出人数")
    @PostMapping("/findByOneMonthAllStationInOut")
    public List<Map> findByOneMonthAllStationInOut(@RequestParam("month") int month){
        return service.findByOneMonthAllStationInOut(month);
    };
    /**
     * 某个月的某一天的单个站点的进出人数
     * @param month
     * @param day
     * @return
     */
    @PostMapping("/findByOneDayStationInOutOfMonth")
    public List<Map> findByOneDayStationInOutOfMonth(@RequestParam("month") int month,@RequestParam("day") String day,
                                                     @RequestParam("station") String station){
        return service.findByOneDayStationInOutOfMonth(month,day,station);
    };
    /**
     * https://gitee.com/sun__xiao/fwwb
     * 某个月的单个站点的进出人数
     * @param month
     * @return
     */
    @ApiOperation(value = "某个月的单个站点的进出人数")
    @PostMapping("/findByOneMonthStationInOut")
    public List<Map> findByOneMonthStationInOut(@RequestParam("month") int month,@RequestParam("station") String station){
        return service.findByOneMonthStationInOut(month,station);
    };


    @ApiOperation("一个星期各天出入站人数  左边折线图 右边饼图")
    @PostMapping("/findWeekInOut")
    public List<WeekInOut> findWeekInOut() {
        List<WeekInOut> weekInOut = new  ArrayList<>();
        weekInOut.add(new WeekInOut(11933, 119333));
        weekInOut.add(new WeekInOut(119495, 119495));
        weekInOut.add(new WeekInOut(119160, 119160));
        weekInOut.add(new WeekInOut(119642, 119642));
        weekInOut.add(new WeekInOut(117413, 117413));
        weekInOut.add(new WeekInOut(99326, 99326));
        weekInOut.add(new WeekInOut(97626, 97626));
        return weekInOut;
    }

    @ApiOperation("一天中各时刻入站和出站人数")
    @PostMapping("/findEveryTimeInOut")
    public List<WeekInOut> findEveryTimeInOut(){
        List<WeekInOut> weekInOut = new  ArrayList<>();
        weekInOut.add(new WeekInOut(12007, 2056, 6));
        weekInOut.add(new WeekInOut(55572, 25934, 7));
        weekInOut.add(new WeekInOut(90108, 96090, 8));
        weekInOut.add(new WeekInOut(46577, 58910, 9));
        weekInOut.add(new WeekInOut(36148, 37302, 10));
        weekInOut.add(new WeekInOut(36804, 35843, 11));
        weekInOut.add(new WeekInOut(40182, 38446, 12));
        weekInOut.add(new WeekInOut(43822, 42150, 13));
        weekInOut.add(new WeekInOut(43847, 43987, 14));
        weekInOut.add(new WeekInOut(44503, 44276, 15));
        weekInOut.add(new WeekInOut(49075, 46427, 16));
        weekInOut.add(new WeekInOut(71836, 58022, 17));
        weekInOut.add(new WeekInOut(84414, 88196, 18));
        weekInOut.add(new WeekInOut(48317, 62988, 19));
        weekInOut.add(new WeekInOut(38126, 41552, 20));
        weekInOut.add(new WeekInOut(33570, 35984, 21));
        weekInOut.add(new WeekInOut(16494, 28659, 22));
        return weekInOut;
    }

    @ApiOperation("票价和人数")
    @PostMapping("/findTicketsAndPeople")
    public List<Ticket> findTicketsAndPeople() {
        List<Ticket> tickets = new ArrayList<>();
        tickets.add(new Ticket(1,30));
        tickets.add(new Ticket(2,238063));
        tickets.add(new Ticket(3,201589));
        tickets.add(new Ticket(4,152346));
        tickets.add(new Ticket(5,99772));
        tickets.add(new Ticket(6,55739));
        tickets.add(new Ticket(7,43909));
        tickets.add(new Ticket(9,281));
        tickets.add(new Ticket(10,54));
        tickets.add(new Ticket(11,59));
        tickets.add(new Ticket(12,23));
        tickets.add(new Ticket(13,26));
        tickets.add(new Ticket(14,27));
        return tickets;
    }

    @ApiOperation("聚类图1")
    @PostMapping("/cluster1")
    public List<Cluster> Cluster1() {
        return service.Cluster1();
    }
}
